package com.zf.nospring.rabbitmq.topic;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.DefaultConsumer;
import com.zf.nospring.rabbitmq.utils.RabbitUtils;

import java.io.IOException;
import java.util.concurrent.TimeoutException;


public class TopicConsumer {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = RabbitUtils.getDefaultConnection();
        Channel channel = connection.createChannel();
        // 创建消费者的消费逻辑
        DefaultConsumer defaultConsumer = RabbitUtils.getDefaultConsumer(channel);
        // 一个通道可以消费多个队列，如果同一个通道消费不同的队列，那么就是两个消费者，他们的 consumerTag 也不同
        channel.basicConsume("test_topic_queue1", true, defaultConsumer);
        channel.basicConsume("test_topic_queue2", true, defaultConsumer);
    }
}


